// 资方
var app = getApp()
var lastClickTime = 0
var minClickTime = app.globalData.minClickTime
var encryptUtils = require('../../../utils/HHEncryptUtils.js')
var modelUtils = require('../../../utils/HHModelUtils.js')
var baseImgPath = app.globalData.imgBasepath
var investor_id

/**
 * 
 * 点击事件处理
 * 
 *
 * 
        var clickTime = Date.now()

         if (clickTime - lastClickTime <= minClickTime) {

            return
         }
         lastClickTime = clickTime
 * 
 * 
 */

Page({

    /**
     * 页面的初始数据
     */
    data: {
        loading: false,
        complate: true,
        noData: false,
        // loading: true,
        // complate: false,
        // noData: false,
        noDataMsg: "暂无数据",
        loaingImg: baseImgPath + app.globalData.loading,
        noDataImg: baseImgPath + app.globalData.no_data,


    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        //   this.getPageData()
        investor_id = options.id
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        this.getPageData()
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {


    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {


    },
    getPageData: function () {

        var para = {}
        para["investor_id"] = encryptUtils.base64Encode(investor_id)
        var str = JSON.stringify(para)
        var urlStr = encodeURIComponent(str)
        console.log("para==" + urlStr)
        var that = this
        wx.request({
            url: app.globalData.ip + "investorinfo",
            method: 'POSt',
            header: {
                'From': "WeChat"
            },
            data: {
                'para': urlStr
            },
            success: function (res) {

                var code = res.data.code
                console.log("result==" + JSON.stringify(res.data))
                if (code == 100) {

                    var needData = res.data.result
                    var info = modelUtils.getModel(needData)
                    that.setData(
                        {
                            info: info,
                            loading: false,
                            complate: true,
                            noData: false,
                        }
                    )

                } else {

                    that.setData(
                        {
                            loading: false,
                            complate: true,
                            noData: true,
                            noDataMsg: "暂无数据"
                        }
                    )
                }
            },

            fail: function (res) {

                that.setData(
                    {
                        loading: false,
                        complate: true,
                        noData: true,
                        noDataMsg: "加载失败，请刷新重试"
                    }
                )
            }
            ,
            complete: function () {
                wx.stopPullDownRefresh()


            }
        }


        )

    },

})